package com.bazhahei.services.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.bazhahei.commons.entity.Student;
import com.bazhahei.services.dao.StudentRepository;
import com.bazhahei.services.service.StudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public class StudServiceImpl implements StudService{
    @Autowired
    private StudentRepository studentRepository;

    @Transactional(propagation = Propagation.REQUIRED)
    public Student save(Student student){
        return studentRepository.save(student);
    }

    public List<Student> findAll(){
        return (List<Student>) studentRepository.findAll();
    }

    public Student findOne(long id){
        return studentRepository.findOne(id);
    }

    public void testImpl(){
        studentRepository.sayHello();
    }
}
